<html>
<head>
<title>Classical.js demo</title>
<script src="classical.js"></script>
<script>
// Here all the test classes are defined

Class('Fruit', {
	'[constructor]': function () {
		output('Creating a Fruit');
	},
	'public publicValue': 'Public variable scoping works!',
	'private privateValue': 'Private variable scoping works!',
	'test': function () {
		output('[Testing values]');
		output(publicValue);
		output(privateValue);
	},
	'public get inheritedGetter': function () {
		return 'Works';
	},
	'private get privateGetter': function () {
		return 'Works';
	},
	'public testPrivateGetter': function () {
		return privateGetter;
	}
});

// flags to see if scoping works
var publicValue = 'Public variable scoping failed.';
var privateValue = 'Private variable scoping failed.';
var privateGetter = 'Fails';

Class('Apple', {
	'[constructor]': function () {
		output('Creating an Apple');
		uberConstructor();
	}
}, Fruit);

Class('Pie', {
	'[constructor]': function () {
		output('Creating a Pie');
		uberConstructor();
	}
}, Apple);

// output function

function output(val) {
	document.getElementById('output').innerHTML += val + '<br>';
}

</script>
</head>
<body>
<h1>Classical demo</h1>
<pre id="output">
</pre>

<script>
// here the demo begins

var fruit = new Fruit();
fruit.test();
output('Public value exists: ' + !!fruit.publicValue);
output('Private value is hidden: ' + !fruit.privateValue);

var apple = new Apple();
apple.publicValue = 'Inherited public variable scoping works!';
apple.test();

var pie = new Pie();
pie.publicValue = 'Double inherited public variable scoping works!';
pie.test();

output('Public getter: ' + fruit.inheritedGetter);
output('Inherited public getter: ' + apple.inheritedGetter);
output('Double inherited public getter: ' + pie.inheritedGetter);
output('Private getter: ' + fruit.testPrivateGetter());
</script>
</body>
</html>